/**
 * 删除留言
 * @param {String} id 留言id
 */
import BaseController from "./common/BaseController"

class DeleteLeaveController extends BaseController {
    constructor() {
        super()
        this.mainMethod = this.mainMethod.bind(this)
        this.state = {
            request: null,
            response: null,
            next: null,
        }
    }

    mainMethod (req, res, next) {
        this.state.request = req
        this.state.response = res
        this.state.next = next
        this.handleBusiness()
    }

    async handleBusiness () {
        const { response, request } = this.state
        const { id } = request.body
        global.query('delete from wd_leave_message where id = ?', response, [id])
        response.json({ code: 1, msg: "删除成功" })
    }
}

export default new DeleteLeaveController().mainMethod
